home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / DDPLUS71.ZIP / OVERLAY.ZIP / INITOVER.PAS next >
Encoding:
Pascal/Delphi Source File  |  1995-03-19  |  4.6 KB  |  141 lines

  1. UNIT InitOver;
  2. (**) INTERFACE (**)
  3. Uses Overlay, Dos, Crt, DDplus;
  4.  
  5. (**) IMPLEMENTATION (**)
  6.  
  7.   (*NOTE: You will have to choose the buffer size
  8.     for each particular program.  The bigger it is,
  9.     the less "thrashing" as the program reads from
  10.     disk.  However, the bigger it is, the less Heap
  11.     memory is available.  Hence we define the buffer
  12.     size in terms of the amount of heap space needed
  13.     by the program.*)
  14.  
  15. CONST
  16.  HeapNeeded = 180000; {Change this to suit your own heap requirements}
  17.  
  18.   PROCEDURE SetUpOverlay;
  19.   VAR
  20.     OverlayName    : String[79];
  21.     BufferSize,
  22.     OrigBufferSize : LongInt;
  23.     N              : Word;
  24.     Message        : Boolean;
  25.     X              : LongInt;
  26.   BEGIN
  27.     Message := FALSE;
  28.     IF Lo(DosVersion) >= 3 THEN
  29.       OverlayName := ParamStr(0)
  30.     ELSE
  31.       BEGIN
  32.         {NOTE - You MUST replace GOC.EXE with your programs main}
  33.         {executable file name}
  34.         OverlayName := FSearch('GOC.EXE',
  35.                                GetEnv('PATH'));
  36.         IF OverlayName = '' THEN
  37.           BEGIN
  38.             Write('The main program must be named');
  39.             WriteLn('"GOC.EXE",');         {Change to your program name}
  40.             Write('and it must reside on your PATH ');
  41.             WriteLn('or in the current directory.');
  42.             Halt( 1 );
  43.           END;
  44.       END;
  45.     WriteLn;
  46.     OverlayName := FExpand(OverlayName);
  47.     {WriteLn('Loading ',OverlayName,'...');}{Add this back in you want it}
  48.     Dec(OverlayName[0], 3);
  49.     OverlayName := OverlayName + 'OVR';
  50.     OvrInit(OverlayName);  {Initializes the overlay manager and opens
  51.                              the overlay file}
  52.  
  53.     IF OvrResult = OvrNotFound THEN
  54.       BEGIN
  55.         Write('Overlay file not found: ');
  56.         WriteLn(OverlayName);
  57.         Halt( 2 );
  58.       END;
  59.     IF OvrResult <> OvrOK THEN
  60.       BEGIN
  61.         WriteLn('Error loading overlay file: ');
  62.         WriteLn(OverlayName);
  63.         Halt( 3 );
  64.       END;
  65.  
  66.     IF EMSOK=True then OvrInitEMS; {Loads the overlay file into EMS
  67.                                     - EMSOK is variable flag set by
  68.                                     Sysop using the /E parameter to
  69.                                     tell us it's OK to use EMS}
  70.  
  71.    IF EMSOK=True then
  72.     Begin
  73.      CASE OvrResult OF
  74.       OvrOK : ; {just continue}
  75.       OvrNoEMSDriver : BEGIN
  76.           {I have commented the next few lines out to prevent these
  77.            messages from being displayed to sysops. If you want them
  78.            back just uncomment them. Be warned though to expect many
  79.            message from your door users about these messages!}
  80.  
  81.           {Write('No EMS driver in system.  Program ');
  82.           WriteLn('will read overlay from disk');}
  83.           Message := TRUE;
  84.         END;
  85.       OvrNoEMSMemory : BEGIN
  86.           {I have commented the next few lines out to prevent these
  87.            messages from being displayed to sysops. If you want them
  88.            back just uncomment them. Be warned though to expect many
  89.            message from your door users about these messages!}
  90.  
  91.           {Write('Not enough EMS memory in system.  ');
  92.           Write('Program will read ');
  93.           WriteLn('overlay from disk');}
  94.           Message := TRUE;
  95.         END;
  96.        ELSE
  97.          WriteLn('Overlay manager error.');
  98.          Halt( 4 );
  99.     END;
  100.     End;
  101.     OrigBufferSize := OvrGetBuf;
  102.     BufferSize:=MaxAvail-HeapNeeded;
  103.     OvrSetBuf(BufferSize);
  104.  
  105.     IF OvrResult <> OvrOK THEN
  106.       BEGIN
  107.           {I have commented the next few lines out to prevent these
  108.            messages from being displayed to sysops. If you want them
  109.            back just uncomment them. Be warned though to expect many
  110.            message from your door users about these messages!}
  111.  
  112.         
  113.         {Write('Could not set overlay buffer to ');
  114.         Write(BufferSize,'.  Remaining at default: ');
  115.         WriteLn(OrigBufferSize);}
  116.         Message := TRUE;
  117.       END;
  118.     IF Message THEN
  119.       BEGIN
  120.        {Note: I have commented new few lines out, if you want them back
  121.         all you have to do is remove the comments. Warning be prepared
  122.         for complaints about the annoying "beep" though from your
  123.         door users!}
  124.        
  125.        { NoSound;
  126.         Sound(1200); Delay(150);
  127.         NoSound; Delay(50);
  128.         Sound(1000); Delay(150);
  129.         NoSound;
  130.         N := 5000;
  131.         REPEAT
  132.           Delay( 1 );
  133.           Dec(N);
  134.         UNTIL (N = 0) OR KeyPressed;
  135.         IF KeyPressed THEN IF ReadKey = #0 THEN;}
  136.       END;
  137.   END;
  138.  
  139. BEGIN
  140.   SetUpOverlay;
  141. END.